package com.wpzf.ndhc.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.wpzf.common.core.utils.ServletUtils;
import com.wpzf.common.core.web.domain.AjaxResult;
import com.wpzf.common.log.annotation.Log;
import com.wpzf.common.log.enums.BusinessType;
import com.wpzf.common.security.service.TokenService;
import com.wpzf.common.security.utils.SecurityUtils;
import com.wpzf.ndhc.domain.*;
import com.wpzf.ndhc.mapper.WpCjTbhcjgSjNdMapper;
import com.wpzf.ndhc.service.*;
import com.wpzf.ndhc.utils.WpzfNdhcExcelUtils;
import com.wpzf.ndhc.utils.WpzfNdhcGdalUtils;
import com.wpzf.system.api.model.LoginUser;
import com.wpzf.zxhc.domain.WpCjDkpw2023DTO;
import com.wpzf.zxhc.domain.WpCjdataUploadDTO;
import com.wpzf.zxhc.mapper.DataUploadMapper;
import com.wpzf.zxhc.utils.MultipleFileUnZip;
import net.lingala.zip4j.exception.ZipException;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import shade.okhttp3.OkHttpClient;
import shade.okhttp3.Request;
import shade.okhttp3.Response;

import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.*;

//省级审核
@RestController
@RequestMapping("/wpzfndhcsjsh")
public class WpzfNdhcSjshController {

    @Value("${tempath}")
    public String tempath;

    @Autowired
    private SqlSessionFactory sqlSessionFactory;

    @Autowired
    private WpzfNdhcXjtbTbBaseService wpzfNdhcXjtbTbBaseService;

    @Autowired
    private WpzfNdhcTbBaseService wpzfNdhcTbBaseService;

    @Autowired
    private TokenService tokenService;

    @Autowired
    private WpzfNdhcCommonSjService wpzfNdhcCommonSjService;

    @Autowired
    private WpzfNdhcAppService wpzfNdhcAppService;

    @Autowired
    private WpzfNdhcShijshService wpzfNdhcShijshService;

    @Autowired
    private WpCjTbhcjgSjNdMapper wpCjTbhcjgSjNdMapper;

    @Autowired
    private WpzfNdhcSjshService wpzfNdhcSjshServiceImpl;

    @Autowired
    WpzfNdhcShijshService wpzfNdhcShijshServiceImpl;

    @RequestMapping(value = "/getshibyPch", method = RequestMethod.POST)
    public AjaxResult getshibyPch(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = wpzfNdhcSjshServiceImpl.getshibyPch(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getxianbyPch", method = RequestMethod.POST)
    public AjaxResult getxianbyPch(@RequestBody Map<String, Object> parm) {
        try {

            List<Map> list = wpzfNdhcSjshServiceImpl.getxianbyPch(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getDkDetailByXzq", method = RequestMethod.POST)
    public AjaxResult getDkDetailByXzq(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = wpzfNdhcSjshServiceImpl.getDkDetailByXzq(parm);
            int total = wpzfNdhcSjshServiceImpl.getDkDetailByXzqCount(parm);
            return AjaxResult.success("获取成功", list, total);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getDkDetailAllByXzq", method = RequestMethod.POST)
    public AjaxResult getDkDetailAllByXzq(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = wpzfNdhcSjshServiceImpl.getDkDetailAllByXzq(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //
    @RequestMapping(value = "/getDkHcInfo", method = RequestMethod.POST)
    public AjaxResult getDkHcInfo(@RequestBody Map<String, Object> parm) {
        String jcbh = parm.get("tbbh") + "";
        if (jcbh.indexOf(",") != -1) {
            String dkbh1 = jcbh.split(",")[0];
            parm.put("jcbh", dkbh1.split("-")[0]);
            parm.replace("tbbh", dkbh1.split("-")[0]);
            parm.put("dkbh", jcbh);
        } else {
            parm.put("jcbh", jcbh.split("-")[0]);
            parm.replace("tbbh", jcbh.split("-")[0]);
            parm.put("dkbh", jcbh);
        }
        try {
            //modelMap
            ModelMap modelMap = wpzfNdhcXjtbTbBaseService.getShowImgs(parm);//jcbh-xzqdm-pch
            //地块信息
            WpCjDkxxbxjNdDTO dkxxbxj2023DTO = wpzfNdhcSjshServiceImpl.getDkInfoByDkbh(parm);//dkbh-pch
            //关联地块信息
            List<WpCjDkxxbxjNdDTO> dkxxbxj2023DTOList = wpzfNdhcSjshServiceImpl.getRelationDkInfoByJcbh(parm);//jcbh-pch
            //核查结果
            WpCjTbhcjgsjNdDTO wpCjTbhcjgSj2023 = wpzfNdhcSjshServiceImpl.getTbHcJgInfo(parm);//tbbh-pch
            //图斑示意图
            List<WpCjTbjtNdDTO> wpCjTbjt2023DTOS = wpzfNdhcTbBaseService.querytbjtBytbbh(parm);//tbbh-xzqdm-pch
            //图斑信息
            List<WpCjTbxxbxjNdDTO> tbxxbxj2023DTOS = wpzfNdhcSjshServiceImpl.getTbInfoByJcbh(parm);//jcbh-pch

            Map<String, Object> map = new HashMap<>();
            map.put("modelMap", modelMap);
            map.put("wpCjDkxxb2023dto", dkxxbxj2023DTO);
            map.put("wpCjDkxxb2023relatedto", dkxxbxj2023DTOList);
            map.put("wpCjTbhcjg2023DTOS", wpCjTbhcjgSj2023);
            map.put("wpCjTbjt2023DTOS", wpCjTbjt2023DTOS);
            map.put("wpCjTbxxb2023DTOS", tbxxbxj2023DTOS);
            return AjaxResult.success("获取成功", map);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    /*保存核查结果*/
    @RequestMapping(value = "/addHcjgSj", method = RequestMethod.POST)
    public AjaxResult addHcjgSj(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        List<Map> list = new ArrayList<>();
        String selectList = parm.get("listParams").toString();
        int rest = 0;
        String ywhj = parm.get("ywhj") + "";
        if (!selectList.equals("") && !selectList.equals("null") && selectList != null) {
            JSONObject obj = JSON.parseObject(selectList);
            if (obj != null) {

                parm.put("username", loginUser.getUsername());
                // parm.put("xzqdm", obj.get("xzqdm"));
                // parm.put("pdlx",obj.get("pdlx"));
                parm.put("pch", obj.get("pch"));

                //parm.put("xzqdm", obj.get("xzqdm"));
                parm.put("shr", loginUser.getSysUser().getNickName());
                parm.put("sfhc", "是");

                parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
                String strPdlx = parm.get("pdlx") + "";
                if (strPdlx.equals("合法")) {
                    parm.put("jl_jlpf", parm.get("hf_jlJlpf"));
                } else if (strPdlx.equals("违法")) {
                    parm.put("jl_jlpf", parm.get("wf_jlJlpf"));
                } else if (strPdlx.equals("其他")) {
                    parm.put("jl_jlpf", parm.get("qt_jlJlpf"));
                }

                String state = parm.get("state") + "";
                Map<String, Object> item = wpzfNdhcCommonSjService.queryHcJgById(parm);
                if (item != null) {
                    wpzfNdhcCommonSjService.deleteHcJg(parm);
                    wpzfNdhcCommonSjService.deleteHcjg_hf_dtPwwj(parm);
                    wpzfNdhcCommonSjService.deleteHcjg_wf_wfpzwh(parm);
                    wpzfNdhcCommonSjService.deleteHcjg_wf_wftgzmwj(parm);
                    wpzfNdhcCommonSjService.deleteHcjg_qt_qtpzwh(parm);
                    wpzfNdhcCommonSjService.deleteHcjg_qt_qtsftgxxydss(parm);
                    wpzfNdhcCommonSjService.deleteHcjg_qt_qtsfzygd(parm);
                }
                rest = wpzfNdhcCommonSjService.addHcjg(parm);
                String domains = parm.get("domains") + "";
                if (!domains.equals("[]") && !domains.equals("null") && domains != "null") {
                    JSONArray arraylist = JSONObject.parseArray(domains);
                    for (int i = 0; i < arraylist.size(); i++) { //遍历输出
                        JSONObject jsonObject = arraylist.getJSONObject(i);
                        String domainType = jsonObject.getString("domainType");
                        if (domainType.equals("domains")) {
                            ModelMap map = new ModelMap();
                            map.put("tbbh", parm.get("tbbh"));
                            map.put("xzqdm", parm.get("xzqdm"));
                            map.put("pch", parm.get("pch"));
                            map.put("sort", jsonObject.getString("key"));
                            map.put("hf_zlpwlx1", jsonObject.getString("hfZlpwlx1"));
                            map.put("hf_pzwh", jsonObject.getString("hfPzwh"));
                            map.put("hf_pzxmmc", jsonObject.getString("hfPzxmmc"));
                            map.put("hf_pzzygdmj", jsonObject.getString("hfPzzygdmj"));
                            map.put("hf_pzzygdmjdw", jsonObject.getString("hfPzzygdmjdw"));
                            map.put("hf_pzsj", jsonObject.getString("hfPzsj"));
                            map.put("hf_zlpwlx2", jsonObject.getString("hfZlpwlx2"));
                            map.put("hf_zlpwclmc", jsonObject.getString("hfZlpwclmc"));
                            map.put("ywhj", parm.get("ywhj"));
                            map.put("status", "");
                            int hf_rest = wpzfNdhcCommonSjService.addHcjg_hf_DtPwwj(map);
                        } else if (domainType.equals("wfpzwh_domains")) {
                            ModelMap map = new ModelMap();
                            map.put("tbbh", parm.get("tbbh"));
                            map.put("xzqdm", parm.get("xzqdm"));
                            map.put("pch", parm.get("pch"));
                            map.put("sort", jsonObject.getString("key"));
                            map.put("wf_pzwh", jsonObject.getString("wfPzwh"));
                            map.put("wf_pzxmmc", jsonObject.getString("wfPzxmmc"));
                            map.put("wf_pzsj", jsonObject.getString("wfPzsj"));
                            map.put("ywhj", parm.get("ywhj"));
                            map.put("status", "");
                            wpzfNdhcCommonSjService.addHcjg_wf_wfpzwh(map);
                        } else if (domainType.equals("wftgzmwj_domains")) {
                            ModelMap map = new ModelMap();
                            map.put("tbbh", parm.get("tbbh"));
                            map.put("xzqdm", parm.get("xzqdm"));
                            map.put("pch", parm.get("pch"));
                            map.put("sort", jsonObject.getString("key"));
                            map.put("wf_zlpwlx1", jsonObject.getString("wfZlpwlx1"));
                            map.put("wf_pzwh", jsonObject.getString("wfPzwh"));
                            map.put("wf_pzxmmc", jsonObject.getString("wfPzxmmc"));
                            map.put("wf_pzzygdmj", jsonObject.getString("wfPzzygdmj"));
                            map.put("wf_pzzygdmjdw", jsonObject.getString("wfPzzygdmjdw"));
                            map.put("wf_pzsj", jsonObject.getString("wfPzsj"));
                            map.put("wf_zlpwlx2", jsonObject.getString("wfZlpwlx2"));
                            map.put("wf_zlpwclmc", jsonObject.getString("wfZlpwclmc"));
                            map.put("ywhj", parm.get("ywhj"));
                            map.put("status", "");
                            wpzfNdhcCommonSjService.addHcjg_wf_wftgzmwj(map);
                        } else if (domainType.equals("qtpzwh_domains")) {
                            ModelMap qtpzwh_map = new ModelMap();
                            qtpzwh_map.put("tbbh", parm.get("tbbh"));
                            qtpzwh_map.put("xzqdm", parm.get("xzqdm"));
                            qtpzwh_map.put("pch", parm.get("pch"));
                            qtpzwh_map.put("sort", jsonObject.getString("key"));
                            qtpzwh_map.put("qt_pzwh", jsonObject.getString("qtPzwh"));
                            qtpzwh_map.put("qt_pzxmmc", jsonObject.getString("qtPzxmmc"));
                            qtpzwh_map.put("qt_pzsj", jsonObject.getString("qtPzsj"));
                            qtpzwh_map.put("ywhj", parm.get("ywhj"));
                            qtpzwh_map.put("status", "");
                            rest = wpzfNdhcCommonSjService.adddHcjg_qt_qtpzwh(qtpzwh_map);
                        } else if (domainType.equals("qtsftgxxydss_domains")) {
                            ModelMap qtsfzygd_map = new ModelMap();
                            qtsfzygd_map.put("tbbh", parm.get("tbbh"));
                            qtsfzygd_map.put("xzqdm", parm.get("xzqdm"));
                            qtsfzygd_map.put("pch", parm.get("pch"));
                            qtsfzygd_map.put("sort", jsonObject.getString("key"));
                            qtsfzygd_map.put("qt_tgbawjsj", jsonObject.getString("qtTgbawjsj"));
                            qtsfzygd_map.put("qt_clmc", jsonObject.getString("qtClmc"));
                            qtsfzygd_map.put("ywhj", parm.get("ywhj"));
                            qtsfzygd_map.put("status", "");
                            rest = wpzfNdhcCommonSjService.addHcjg_qt_qtsfzygd(qtsfzygd_map);
                        } else if (domainType.equals("qtsfzygd_domains")) {
                            ModelMap qtsftgxxydss_map = new ModelMap();
                            qtsftgxxydss_map.put("tbbh", parm.get("tbbh"));
                            qtsftgxxydss_map.put("xzqdm", parm.get("xzqdm"));
                            qtsftgxxydss_map.put("pch", parm.get("pch"));
                            qtsftgxxydss_map.put("sort", jsonObject.getString("key"));
                            qtsftgxxydss_map.put("qt_sftgxxydssclmc", jsonObject.getString("qtSftgxxydssclmc"));
                            qtsftgxxydss_map.put("qt_sftgxxydsspfsj", jsonObject.getString("qtSftgxxydsspfsj"));
                            qtsftgxxydss_map.put("ywhj", parm.get("ywhj"));
                            qtsftgxxydss_map.put("status", "");
                            rest = wpzfNdhcCommonSjService.addHcjg_qt_qtsftgxxydss(qtsftgxxydss_map);
                        }
                    }
                }


                Map<String, Object> map = new HashMap<>();
                map.put("ids", parm.get("ids"));
                map.put("pch", parm.get("pch"));
                map.put("xzqdm", obj.getString("xzqdm"));
                list = wpzfNdhcSjshServiceImpl.getDkDetailAllByIndex(map);

            }
            if (("合法").equals(parm.get("pdlx").toString())) {
                //按照业务环节值  获取核查结果说明
                if (parm.get("hf_zphlxjc") != "") {
                    Map<String, Object> tbhcjgsm = wpzfNdhcCommonSjService.getHcjgsmBytbbh(parm);
                    if (tbhcjgsm != null) {
                        tbhcjgsm.put("username", loginUser.getUsername());
                        tbhcjgsm.put("ywhj", parm.get("ywhj") + "");
                        wpzfNdhcCommonSjService.updateHcjg_hcjgsm(tbhcjgsm);  //更新核查结果说明
                    }
                }
            } else if (("违法").equals(parm.get("pdlx").toString())) {
                //按照业务环节值  获取核查结果说明
                if (parm.get("wf_zphlxjc") != "") {
                    Map<String, Object> tbhcjgsm = wpzfNdhcCommonSjService.getHcjgsmBytbbh(parm);
                    if (tbhcjgsm != null) {
                        tbhcjgsm.put("username", loginUser.getUsername());
                        tbhcjgsm.put("ywhj", parm.get("ywhj") + "");
                        wpzfNdhcCommonSjService.updateHcjg_hcjgsm(tbhcjgsm);  //更新核查结果说明
                    }
                }
            } else if (("其他").equals(parm.get("pdlx").toString())) {
                //按照业务环节值  获取核查结果说明
                if (parm.get("qt_zphlxjc") != "") {
                    Map<String, Object> tbhcjgsm = wpzfNdhcCommonSjService.getHcjgsmBytbbh(parm);
                    if (tbhcjgsm != null) {
                        tbhcjgsm.put("username", loginUser.getUsername());
                        tbhcjgsm.put("ywhj", parm.get("ywhj") + "");
                        wpzfNdhcCommonSjService.updateHcjg_hcjgsm(tbhcjgsm);  //更新核查结果说明
                    }
                }
            }
        }

        return AjaxResult.success("添加核查结果", list, rest);
    }

    @RequestMapping(value = "/getDkDetailAllByIndex", method = RequestMethod.POST)
    public AjaxResult getDkDetailAllByIndex(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = wpzfNdhcSjshServiceImpl.getDkDetailAllByIndex(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //退回
    @RequestMapping(value = "/dkshSjSubmit", method = RequestMethod.POST)
    public AjaxResult dkshSjSubmit(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("czr", loginUser.getUsername());
            parm.put("realname", loginUser.getSysUser().getNickName());
            Integer nCount = wpzfNdhcSjshServiceImpl.dkshSjSubmit(parm); //状态修改
            if (nCount == -1) {
                return AjaxResult.success("该区县存在未审核地块，无法进行提交", nCount);
            }
            return AjaxResult.success("退回成功", nCount);
        } catch (Exception ex) {
            return AjaxResult.error("退回失败", ex.toString());
        }
    }


    //提交 按照行政区划修改
    @RequestMapping(value = "/dkshDgSubmit", method = RequestMethod.POST)
    public AjaxResult dkshDgSubmit(@RequestBody Map<String, Object> parm) {
        try {

            Integer nCount = wpzfNdhcSjshServiceImpl.dkshDgSubmit(parm);
            if (nCount == -1) {
                return AjaxResult.success("该区县存在未审核地块，无法进行提交", nCount);
            }
            return AjaxResult.success("提交成功", nCount);
        } catch (Exception ex) {
            return AjaxResult.error("提交失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getDkHcZzJgInfo", method = RequestMethod.POST)
    public AjaxResult getDkHcZzJgInfo(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("xzqdm", loginUser.getSysUser().getXzqdm());
            List<Map> list = wpzfNdhcSjshServiceImpl.getDkHcZzJgInfo(parm);
            Integer total = wpzfNdhcSjshServiceImpl.getDkHcZzJgInfoCount(parm);
            return AjaxResult.success("获取成功", list, total);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getDkHcZzJgPch", method = RequestMethod.GET)
    public AjaxResult getDkHcZzJgPch() {
        try {
//            Map parm = new HashMap();
//            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
//            parm.put("xzqdm", loginUser.getSysUser().getXzqdm());
//            List<Map> list = wpzfNdhcSjshServiceImpl.getDkHcZzJgPch(parm);
            return AjaxResult.success("获取成功", new ArrayList<>());
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getDkHcJgByXzq", method = RequestMethod.POST)
    public AjaxResult getDkHcJgByXzq(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = wpzfNdhcSjshServiceImpl.getDkHcJgByXzq(parm);
            Integer total = wpzfNdhcSjshServiceImpl.getDkHcJgByXzqCount(parm);
            return AjaxResult.success("获取成功", list, total);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getBtgDkJgAll", method = RequestMethod.POST)
    public AjaxResult getBtgDkJgAll(@RequestBody Map<String, Object> parm) {
        try {
            String xzqdm = parm.get("xzqdm").toString();
            if (xzqdm.equals("")) {
                LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
                parm.put("xzqdm", loginUser.getSysUser().getXzqdm());
            }
            List<Map> list = wpzfNdhcSjshServiceImpl.getBtgDkJgAll(parm);
            Integer total = wpzfNdhcSjshServiceImpl.getBtgDkJgAllCount(parm);
            return AjaxResult.success("获取成功", list, total);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getBtgDkPch", method = RequestMethod.GET)
    public AjaxResult getBtgDkPch() {
        try {
            Map parm = new HashMap();
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("xzqdm", loginUser.getSysUser().getXzqdm());
            List<Map> list = wpzfNdhcSjshServiceImpl.getBtgDkPch(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getBtgDkXzqh", method = RequestMethod.POST)
    public AjaxResult getBtgDkXzqh(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("xzqdm", loginUser.getSysUser().getXzqdm());
            List<Map> list = wpzfNdhcSjshServiceImpl.getBtgDkXzqh(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getBtgDkList", method = RequestMethod.POST)
    public AjaxResult getBtgDkList(@RequestBody Map<String, Object> parm) {
        try {
            String xzqdm = parm.get("xzqdm").toString();
            if (xzqdm.equals("") || xzqdm == null) {
                LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
                parm.replace("xzqdm", loginUser.getSysUser().getXzqdm());
            }
            List<Map> list = wpzfNdhcSjshServiceImpl.getBtgDkList(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getBtgDkJgAllByIndex", method = RequestMethod.POST)
    public AjaxResult getBtgDkJgAllByIndex(@RequestBody Map<String, Object> parm) {
        try {
            String xzqdm = parm.get("xzqdm").toString();
            if (xzqdm.equals("") || xzqdm == null) {
                LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
                parm.replace("xzqdm", loginUser.getSysUser().getXzqdm());
            }
            List<Map> list = wpzfNdhcSjshServiceImpl.getBtgDkJgAllByIndex(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    /*保存核查结果*/
    @RequestMapping(value = "/addBtgHcjgSj", method = RequestMethod.POST)
    public AjaxResult addBtgHcjgSj(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        List<Map> list = new ArrayList<>();
        String selectList = parm.get("listParams").toString();
        int rest = 0;
        String ywhj = parm.get("ywhj") + "";
        if (!selectList.equals("") && !selectList.equals("null") && selectList != null) {
            JSONObject obj = JSON.parseObject(selectList);
            if (obj != null) {

                parm.put("username", loginUser.getUsername());
                // parm.put("xzqdm", obj.get("xzqdm"));
                // parm.put("pdlx",obj.get("pdlx"));
                parm.put("pch", obj.get("pch"));

                //parm.put("xzqdm", obj.get("xzqdm"));
                parm.put("shr", loginUser.getSysUser().getNickName());
                parm.put("sfhc", "是");

                parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
                String strPdlx = parm.get("pdlx") + "";
                if (strPdlx.equals("合法")) {
                    parm.put("jl_jlpf", parm.get("hf_jlJlpf"));
                } else if (strPdlx.equals("违法")) {
                    parm.put("jl_jlpf", parm.get("wf_jlJlpf"));
                } else if (strPdlx.equals("其他")) {
                    parm.put("jl_jlpf", parm.get("qt_jlJlpf"));
                }

                String state = parm.get("state") + "";
                Map<String, Object> item = wpzfNdhcCommonSjService.queryHcJgById(parm);
                if (item != null) {
                    wpzfNdhcCommonSjService.deleteHcJg(parm);
                    wpzfNdhcCommonSjService.deleteHcjg_hf_dtPwwj(parm);
                    wpzfNdhcCommonSjService.deleteHcjg_wf_wfpzwh(parm);
                    wpzfNdhcCommonSjService.deleteHcjg_wf_wftgzmwj(parm);
                    wpzfNdhcCommonSjService.deleteHcjg_qt_qtpzwh(parm);
                    wpzfNdhcCommonSjService.deleteHcjg_qt_qtsftgxxydss(parm);
                    wpzfNdhcCommonSjService.deleteHcjg_qt_qtsfzygd(parm);
                }
                rest = wpzfNdhcCommonSjService.addHcjg(parm);
                String domains = parm.get("domains") + "";
                if (!domains.equals("[]") && !domains.equals("null") && domains != "null") {
                    JSONArray arraylist = JSONObject.parseArray(domains);
                    for (int i = 0; i < arraylist.size(); i++) { //遍历输出
                        JSONObject jsonObject = arraylist.getJSONObject(i);
                        String domainType = jsonObject.getString("domainType");
                        if (domainType.equals("domains")) {
                            ModelMap map = new ModelMap();
                            map.put("tbbh", parm.get("tbbh"));
                            map.put("xzqdm", parm.get("xzqdm"));
                            map.put("pch", parm.get("pch"));
                            map.put("sort", jsonObject.getString("key"));
                            map.put("hf_zlpwlx1", jsonObject.getString("hfZlpwlx1"));
                            map.put("hf_pzwh", jsonObject.getString("hfPzwh"));
                            map.put("hf_pzxmmc", jsonObject.getString("hfPzxmmc"));
                            map.put("hf_pzzygdmj", jsonObject.getString("hfPzzygdmj"));
                            map.put("hf_pzzygdmjdw", jsonObject.getString("hfPzzygdmjdw"));
                            map.put("hf_pzsj", jsonObject.getString("hfPzsj"));
                            map.put("hf_zlpwlx2", jsonObject.getString("hfZlpwlx2"));
                            map.put("hf_zlpwclmc", jsonObject.getString("hfZlpwclmc"));
                            map.put("ywhj", parm.get("ywhj"));
                            map.put("status", "");
                            int hf_rest = wpzfNdhcCommonSjService.addHcjg_hf_DtPwwj(map);
                        } else if (domainType.equals("wfpzwh_domains")) {
                            ModelMap map = new ModelMap();
                            map.put("tbbh", parm.get("tbbh"));
                            map.put("xzqdm", parm.get("xzqdm"));
                            map.put("pch", parm.get("pch"));
                            map.put("sort", jsonObject.getString("key"));
                            map.put("wf_pzwh", jsonObject.getString("wfPzwh"));
                            map.put("wf_pzxmmc", jsonObject.getString("wfPzxmmc"));
                            map.put("wf_pzsj", jsonObject.getString("wfPzsj"));
                            map.put("ywhj", parm.get("ywhj"));
                            map.put("status", "");
                            wpzfNdhcCommonSjService.addHcjg_wf_wfpzwh(map);
                        } else if (domainType.equals("wftgzmwj_domains")) {
                            ModelMap map = new ModelMap();
                            map.put("tbbh", parm.get("tbbh"));
                            map.put("xzqdm", parm.get("xzqdm"));
                            map.put("pch", parm.get("pch"));
                            map.put("sort", jsonObject.getString("key"));
                            map.put("wf_zlpwlx1", jsonObject.getString("wfZlpwlx1"));
                            map.put("wf_pzwh", jsonObject.getString("wfPzwh"));
                            map.put("wf_pzxmmc", jsonObject.getString("wfPzxmmc"));
                            map.put("wf_pzzygdmj", jsonObject.getString("wfPzzygdmj"));
                            map.put("wf_pzzygdmjdw", jsonObject.getString("wfPzzygdmjdw"));
                            map.put("wf_pzsj", jsonObject.getString("wfPzsj"));
                            map.put("wf_zlpwlx2", jsonObject.getString("wfZlpwlx2"));
                            map.put("wf_zlpwclmc", jsonObject.getString("wfZlpwclmc"));
                            map.put("ywhj", parm.get("ywhj"));
                            map.put("status", "");
                            wpzfNdhcCommonSjService.addHcjg_wf_wftgzmwj(map);
                        } else if (domainType.equals("qtpzwh_domains")) {
                            ModelMap qtpzwh_map = new ModelMap();
                            qtpzwh_map.put("tbbh", parm.get("tbbh"));
                            qtpzwh_map.put("xzqdm", parm.get("xzqdm"));
                            qtpzwh_map.put("pch", parm.get("pch"));
                            qtpzwh_map.put("sort", jsonObject.getString("key"));
                            qtpzwh_map.put("qt_pzwh", jsonObject.getString("qtPzwh"));
                            qtpzwh_map.put("qt_pzxmmc", jsonObject.getString("qtPzxmmc"));
                            qtpzwh_map.put("qt_pzsj", jsonObject.getString("qtPzsj"));
                            qtpzwh_map.put("ywhj", parm.get("ywhj"));
                            qtpzwh_map.put("status", "");
                            rest = wpzfNdhcCommonSjService.adddHcjg_qt_qtpzwh(qtpzwh_map);
                        } else if (domainType.equals("qtsftgxxydss_domains")) {
                            ModelMap qtsfzygd_map = new ModelMap();
                            qtsfzygd_map.put("tbbh", parm.get("tbbh"));
                            qtsfzygd_map.put("xzqdm", parm.get("xzqdm"));
                            qtsfzygd_map.put("pch", parm.get("pch"));
                            qtsfzygd_map.put("sort", jsonObject.getString("key"));
                            qtsfzygd_map.put("qt_tgbawjsj", jsonObject.getString("qtTgbawjsj"));
                            qtsfzygd_map.put("qt_clmc", jsonObject.getString("qtClmc"));
                            qtsfzygd_map.put("ywhj", parm.get("ywhj"));
                            qtsfzygd_map.put("status", "");
                            rest = wpzfNdhcCommonSjService.addHcjg_qt_qtsfzygd(qtsfzygd_map);
                        } else if (domainType.equals("qtsfzygd_domains")) {
                            ModelMap qtsftgxxydss_map = new ModelMap();
                            qtsftgxxydss_map.put("tbbh", parm.get("tbbh"));
                            qtsftgxxydss_map.put("xzqdm", parm.get("xzqdm"));
                            qtsftgxxydss_map.put("pch", parm.get("pch"));
                            qtsftgxxydss_map.put("sort", jsonObject.getString("key"));
                            qtsftgxxydss_map.put("qt_sftgxxydssclmc", jsonObject.getString("qtSftgxxydssclmc"));
                            qtsftgxxydss_map.put("qt_sftgxxydsspfsj", jsonObject.getString("qtSftgxxydsspfsj"));
                            qtsftgxxydss_map.put("ywhj", parm.get("ywhj"));
                            qtsftgxxydss_map.put("status", "");
                            rest = wpzfNdhcCommonSjService.addHcjg_qt_qtsftgxxydss(qtsftgxxydss_map);
                        }
                    }
                }
                Map<String, Object> map = new HashMap<>();
                map.put("ids", parm.get("ids"));
                map.put("pch", parm.get("pch"));
                map.put("xzqdm", obj.getString("xzqdm"));
                list = wpzfNdhcSjshServiceImpl.getBtgDkJgAllByIndex(map);

            }
        }
        //按照业务环节值  获取核查结果说明
        if (("合法").equals(parm.get("pdlx").toString())) {
            //按照业务环节值  获取核查结果说明
            if (parm.get("hf_zphlxjc") != "") {
                Map<String, Object> tbhcjgsm = wpzfNdhcCommonSjService.getHcjgsmBytbbh(parm);
                if (tbhcjgsm != null) {
                    tbhcjgsm.put("username", loginUser.getUsername());
                    tbhcjgsm.put("ywhj", parm.get("ywhj") + "");
                    wpzfNdhcCommonSjService.updateHcjg_hcjgsm(tbhcjgsm);  //更新核查结果说明
                }
            }
        } else if (("违法").equals(parm.get("pdlx").toString())) {
            //按照业务环节值  获取核查结果说明
            if (parm.get("wf_zphlxjc") != "") {
                Map<String, Object> tbhcjgsm = wpzfNdhcCommonSjService.getHcjgsmBytbbh(parm);
                if (tbhcjgsm != null) {
                    tbhcjgsm.put("username", loginUser.getUsername());
                    tbhcjgsm.put("ywhj", parm.get("ywhj") + "");
                    wpzfNdhcCommonSjService.updateHcjg_hcjgsm(tbhcjgsm);  //更新核查结果说明
                }
            }
        } else if (("其他").equals(parm.get("pdlx").toString())) {
            //按照业务环节值  获取核查结果说明
            if (parm.get("qt_zphlxjc") != "") {
                Map<String, Object> tbhcjgsm = wpzfNdhcCommonSjService.getHcjgsmBytbbh(parm);
                if (tbhcjgsm != null) {
                    tbhcjgsm.put("username", loginUser.getUsername());
                    tbhcjgsm.put("ywhj", parm.get("ywhj") + "");
                    wpzfNdhcCommonSjService.updateHcjg_hcjgsm(tbhcjgsm);  //更新核查结果说明
                }
            }
        }
        return AjaxResult.success("添加核查结果", list, rest);
    }

    @RequestMapping(value = "/btgDkshSjSubmit", method = RequestMethod.POST)
    public AjaxResult btgDkshSjSubmit(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("username", loginUser.getUsername());
            Integer nCount = wpzfNdhcSjshServiceImpl.btgDkshSjSubmit(parm);
            if (nCount == -1) {
                return AjaxResult.success("该区县存在未审核地块，无法进行提交", nCount);
            }
            return AjaxResult.success("提交成功", nCount);
        } catch (Exception ex) {
            return AjaxResult.error("提交失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getProvExtractionrecordYear", method = RequestMethod.POST)
    public AjaxResult getProvExtractionrecordYear(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = wpzfNdhcSjshServiceImpl.getProvExtractionrecordYear(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getProvExtractionrecordPc", method = RequestMethod.POST)
    public AjaxResult getProvExtractionrecordPc(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = wpzfNdhcSjshServiceImpl.getProvExtractionrecordPc(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getProvExtractionrecord", method = RequestMethod.POST)
    public AjaxResult getProvExtractionrecord(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = wpzfNdhcSjshServiceImpl.getProvExtractionrecord(parm);
            Integer total = wpzfNdhcSjshServiceImpl.getProvExtractionrecordCount(parm);
            return AjaxResult.success("获取成功", list, total);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getProvExtractionData", method = RequestMethod.POST)
    public AjaxResult getProvExtractionData(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = wpzfNdhcSjshServiceImpl.getProvExtractionData(parm);
            Integer total = wpzfNdhcSjshServiceImpl.getProvExtractionDataCount(parm);
            return AjaxResult.success("获取成功", list, total);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getProvExtractionDatasmc1", method = RequestMethod.POST)
    public AjaxResult getProvExtractionDatasmc1(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = wpzfNdhcSjshServiceImpl.getProvExtractionDatasmc1(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getWyname", method = RequestMethod.POST)
    public AjaxResult getWyname(@RequestBody Map<String, Object> parm) {
        try {
            if (parm.get("xzqdm").toString() != "") {
                parm.replace("xzqdm", parm.get("xzqdm").toString().substring(0, 2));
            }
            List<String> list = wpzfNdhcSjshServiceImpl.getWyname(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getProvExtractionDataqxmc", method = RequestMethod.POST)
    public AjaxResult getProvExtractionDataqxmc(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = wpzfNdhcSjshServiceImpl.getProvExtractionDataqxmc(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    /*数据导入*/
    @Log(title = "数据导入", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/uploadFileZip", method = RequestMethod.POST)
    public AjaxResult uploadFileZip(MultipartFile file, String year, String pc, String name, String radio, String xzqdm) {
        try {
            //获得文件名称
            String fileName = file.getOriginalFilename();

            //获得文件后缀名
            String type = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();

            //判断上传的是否是压缩包
            if (!type.equals("zip") && !type.equals("rar")) {
                return AjaxResult.error("请上传文件压缩包");
            }
            //上传唯一值
            String bsm = UUID.randomUUID().toString().replace("-", "");
            WpCjdataUploadDTO task = new WpCjdataUploadDTO();
            task.czr = SecurityUtils.getUsername();
            task.czdate = new Date();
            task.id = bsm;
            task.taskname = name;
            task.iswyname = radio;
            task.year = year;
            task.pc = pc;
            task.xzqdm = xzqdm;
            List<WpCjdataUploadDTO> models = new ArrayList<WpCjdataUploadDTO>();


            String sFilePath = wpzfNdhcSjshServiceImpl.uploadFile(file); //上传文件
            if (sFilePath != "") {
                task.filepath = sFilePath;
                String res = wpzfNdhcSjshServiceImpl.importDataByshp(sFilePath, bsm);
                if (res.equals("")) {
                    task.status = "导入成功";
                    models.add(task);
                    InsertBatch(models);
                    return AjaxResult.success("数据导入成功");
                } else {
                    task.status = "导入失败," + res;
                    models.add(task);
                    InsertBatch(models);
                    return AjaxResult.error("数据导入失败", res);
                }
            }

        } catch (Exception ex) {
            return AjaxResult.error("数据导入失败", ex.toString());
        }
        return AjaxResult.error("数据导入失败");
    }

    @Transactional
    public boolean InsertBatch(List<WpCjdataUploadDTO> models) {
        SqlSession sqlSession = null;
        try {
            //使用批处理
            sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
            DataUploadMapper dataUploadMapper = sqlSession.getMapper(DataUploadMapper.class);
            models.stream().forEach(datauploadDao -> dataUploadMapper.insert(datauploadDao));
            sqlSession.commit();
            return true;
        } catch (Exception ex) {
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            ex.printStackTrace();
            return false;
        } finally {
            // 确保SqlSession被关闭
            if (sqlSession != null) {
                sqlSession.close();
            }
        }
    }

    public String method(Object object) {
        String obj = object != null ? object.toString() : "";
        return obj;
    }

    //省级地块审核详情
    @RequestMapping(value = "/getShengShTaskInfo", method = RequestMethod.POST)
    public AjaxResult getShengShTaskInfo(@RequestBody Map<String, Object> parm) {
        String jcbh = parm.get("jcbh") + "";
        parm.put("tbbh", parm.get("dkbh"));
        if (jcbh.indexOf(",") != -1) {
            parm.put("jcbh", jcbh.split("-")[0]);
        }
        try {
            WpCjTbBaseinfosjNdDTO wpcjTbBaseinfosjDTO = new WpCjTbBaseinfosjNdDTO();
            List<WpCjDkpw2023DTO> lists = new ArrayList<>();
            //获取地块信息  dkxxbxj2023DTOS
            WpCjDkxxbxjNdDTO wpcjDkxxb2023DTO = wpzfNdhcShijshService.getDkInfoByDkbh(parm);
            wpcjTbBaseinfosjDTO.setWpCjDkxxb2023dto(wpcjDkxxb2023DTO);

            //获取图斑信息 相关图斑全部查出
            List<WpCjTbxxbxjNdDTO> wpCjTbxxb2023DTOS = wpzfNdhcShijshService.getTbxxbxjByJcbhList(parm);
            wpcjTbBaseinfosjDTO.setWpCjTbxxb2023DTOS(wpCjTbxxb2023DTOS);


            //其他相关的拆分图斑
            List<WpCjDkxxbxjNdDTO> wpCjDkxxb2023relatedto = wpzfNdhcXjtbTbBaseService.queryWpCjDkInfoByJcbh(parm);
            wpcjTbBaseinfosjDTO.setWpCjDkxxb2023relatedto(wpCjDkxxb2023relatedto);


            //获取举证照片
            parm.put("sfzz", "自主提取".equals(wpCjTbxxb2023DTOS.get(0).getGjxfhzztq()) ? "1" : "0");
            WpCjGsinfolyNdDTO gsinfoly = wpzfNdhcXjtbTbBaseService.getGsinfoly(parm);

            wpcjTbBaseinfosjDTO.setWpCjGsinfolyNdDTO(gsinfoly);

            ModelMap modelMap = new ModelMap();
            if ("0".equals(gsinfoly.getInfoly())) {
                modelMap = wpzfNdhcXjtbTbBaseService.getShowImgsnew(parm);
            } else if ("1".equals(gsinfoly.getInfoly())) {
                List<String> list = new ArrayList<>();
                list.add(wpzfNdhcAppService.getInfo(parm));
//                System.out.println(list);
                modelMap.put("data", list);
            }
            wpcjTbBaseinfosjDTO.setModelMap(modelMap);

            //获取图斑截图
            List<WpCjTbjtNdDTO> wpCjTbjt2023DTOS = wpzfNdhcXjtbTbBaseService.querytbjtBytbbhsheng1(parm);
            wpcjTbBaseinfosjDTO.setWpCjTbjt2023DTOS(wpCjTbjt2023DTOS);

            //获取市级审核信息
            WpCjTbhcjgshijNdDTO tbhcjgshijByDkbh = wpzfNdhcShijshService.getTbhcjgshijByDkbh(parm);
            wpcjTbBaseinfosjDTO.setWpCjTbhcjgshij2023(tbhcjgshijByDkbh);

            //获取省级审核信息
            WpCjTbhcjgshengj tbhcjgshengjByDkbh = wpzfNdhcSjshServiceImpl.getTbhcjgshengjByDkbh(parm);
            wpcjTbBaseinfosjDTO.setWpCjTbhcjgshengj(tbhcjgshengjByDkbh);


            return AjaxResult.success("获取成功", wpcjTbBaseinfosjDTO);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //暂存
    @RequestMapping(value = "/saveShengTbjg", method = RequestMethod.POST)
    public AjaxResult saveShengTbjg(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("czr", loginUser.getUsername());
            parm.put("realname", loginUser.getSysUser().getNickName());
            parm.put("shr", loginUser.getSysUser().getNickName());
            parm.put("username", loginUser.getUsername());
            Integer rest = wpzfNdhcSjshServiceImpl.saveShengTbjg(parm);
            return AjaxResult.success("保存 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("保存 失败", ex.toString());
        }
    }

    //提交
    @RequestMapping(value = "/shengSubmit", method = RequestMethod.POST)
    public AjaxResult shengSubmit(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("czr", loginUser.getUsername());
            parm.put("realname", loginUser.getSysUser().getNickName());
            parm.put("shr", loginUser.getSysUser().getNickName());
            parm.put("username", loginUser.getUsername());
            Integer rest = wpzfNdhcSjshServiceImpl.shengSubmit(parm);
            return AjaxResult.success("提交 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("提交 失败", ex.toString());
        }
    }

    //获取合法信息
    @Log(title = "获取合法-核查结果", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/getHftgzmwj", method = RequestMethod.POST)
    AjaxResult getHftgzmwj(@RequestBody Map<String, Object> parms) {
        try {
            List<WpCjTbhcjgSjNdHftgzmwjDTO> wpCjTbhcjgHftgzmwj2023DTOS = wpCjTbhcjgSjNdMapper.getTbhcjgSjHftgzmwjInfo(parms);
            return AjaxResult.success("获取成功", wpCjTbhcjgHftgzmwj2023DTOS);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //获取违法证明文件
    @Log(title = "获取违法-证明文件", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/getWftgzmwj", method = RequestMethod.POST)
    AjaxResult getWftgzmwj(@RequestBody Map<String, Object> parms) {
        try {
            List<WpCjTbhcjgSjNdWftgzmwjDTO> wpCjTbhcjgWftgzmwj2023DTO = wpCjTbhcjgSjNdMapper.getTbhcjgSjWftgzmwjInfo(parms);
            return AjaxResult.success("获取成功", wpCjTbhcjgWftgzmwj2023DTO);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //获取违法批准文号
    @Log(title = "获取违法-批准文号", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/getWfpzwh", method = RequestMethod.POST)
    AjaxResult getWfpzwh(@RequestBody Map<String, Object> parms) {
        try {
            List<WpCjTbhcjgSjNdWfpzwhDTO> wpCjTbhcjgWfpzwh2023DTO = wpCjTbhcjgSjNdMapper.getTbhcjgSjWfpzwhInfo(parms);
            return AjaxResult.success("获取成功", wpCjTbhcjgWfpzwh2023DTO);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //获取其他批准文号
    @Log(title = "获取其他-批准文号", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/getQtpzwh", method = RequestMethod.POST)
    AjaxResult getQtpzwh(@RequestBody Map<String, Object> parms) {
        try {
            List<WpCjTbhcjgSjNdQtpzwhDTO> rest = wpCjTbhcjgSjNdMapper.getTbhcjgSjQtpzwhInfo(parms);
            return AjaxResult.success("获取成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //获取其他是否占用耕地
    @Log(title = "获取其他-是否占用耕地", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/getQtsfzygd", method = RequestMethod.POST)
    AjaxResult getQtsfzygd(@RequestBody Map<String, Object> parms) {
        try {
            List<WpCjTbhcjgSjNdQtsfzygdDTO> rest = wpCjTbhcjgSjNdMapper.getTbhcjgSjQtsfzygdInfo(parms);
            return AjaxResult.success("获取成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //获取其他提供先行用地手续
    @Log(title = "获取其他-提供先行用地手续", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/getQtsftgxxydss", method = RequestMethod.POST)
    AjaxResult getQtsftgxxydss(@RequestBody Map<String, Object> parms) {
        try {
            List<WpCjTbhcjgSjNdQtsftgxxydssDTO> rest = wpCjTbhcjgSjNdMapper.getTbhcjgSjQtsftgxxydssInfo(parms);
            return AjaxResult.success("获取成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //获取附件信息
    @Log(title = "获取附件信息", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/queryFjInfo", method = RequestMethod.POST)
    public AjaxResult queryFjInfo(@RequestBody Map<String, Object> parms) {
        try {
            List<Map<String, Object>> rest = wpzfNdhcSjshServiceImpl.queryFjInfo(parms);
            if (rest != null && rest.size() > 0) {
                for (int i = 0; i < rest.size(); i++) {
                    String fjUrl = rest.get(i).get("fjurl").toString();
                    rest.get(i).put("fjurl1", downloadFile(fjUrl, "preview"));
                }
            }
            return AjaxResult.success("获取附件信息 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("获取附件信息 失败", ex.toString());
        }
    }

    public String downloadFile(String fileUrl, String action) throws Exception {
        OkHttpClient client = new OkHttpClient();

        Request.Builder requestBuilder = new Request.Builder().url(fileUrl);
        String fileName = fileUrl.substring(fileUrl.lastIndexOf('/') + 1);
        // 设置请求头
        if ("download".equals(action)) {
            requestBuilder.addHeader("Content-Disposition", "attachment; filename=pdf-file.pdf");
        } else {
            requestBuilder.addHeader("Content-Disposition", "inline; filename=pdf-file.pdf");
        }

        Request request = requestBuilder.build();
        Response response = client.newCall(request).execute();
        String saveFilePath = tempath + "\\" + fileName;  // 存储路径  // 存储路径
        if (response.isSuccessful()) {
            InputStream inputStream = response.body().byteStream();


            FileOutputStream outputStream = new FileOutputStream(saveFilePath);
            byte[] buffer = new byte[1024];
            int bytesRead;
            while ((bytesRead = inputStream.read(buffer)) != -1) {
                outputStream.write(buffer, 0, bytesRead);
            }

            outputStream.close();
            inputStream.close();
            return saveFilePath;
//        URL url = new URL(fileUrl);
//        HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
//        String file = url.getFile();
//        String fileName = file.substring(file.lastIndexOf('/') + 1);
//        // 设置请求头
//        if ("download".equals(action)) {
//            httpConn.setRequestProperty("Content-Disposition", "attachment; filename="+fileName);
//        } else {
//            httpConn.setRequestProperty("Content-Disposition", "inline; filename="+fileName);
//        }
//        httpConn.setConnectTimeout(3000);
//        // 限制输入流等待数据到达的时间，超时将会抛出java.net.SocketTimeoutException
//        httpConn.setReadTimeout(3000);
//        // 设定请求的方法为"POST"，默认是GET
//        httpConn.setRequestMethod("POST");
//        // 设置传送的内容类型是json格式
//        httpConn.setRequestProperty("Content-Type", "application/json;charset=utf-8");
//        // 接收的内容类型也是json格式
//        httpConn.setRequestProperty("Accept", "application/json;charset=utf-8");
//        // 设置是否从httpUrlConnection读入，默认情况下是true
//        httpConn.setDoInput(true);
//        // 由于URLConnection在默认的情况下不允许输出，所以在请求输出流之前必须调用setDoOutput(true)。为一个HTTP URL将doOutput设置为true时，请求方法将由GET变为POST
//        httpConn.setDoOutput(true);
//        // 是否使用缓存，Post方式不能使用缓存
//        httpConn.setUseCaches(false);
//
//        InputStream inputStream = httpConn.getInputStream();
//        String saveFilePath = tempath+"\\"+fileName;  // 存储路径
//
//        FileOutputStream outputStream = new FileOutputStream(saveFilePath);
//        BufferedInputStream bis = new BufferedInputStream(inputStream);
//        byte[] buffer = new byte[1024];
//        int bytesRead;
//        while ((bytesRead = bis.read(buffer)) != -1) {
//            outputStream.write(buffer, 0, bytesRead);
//        }
//
//        outputStream.close();
//        bis.close();
//        inputStream.close();
//        httpConn.disconnect();
//
//
        }
        return saveFilePath;
    }

    //保存退回原因
    @Log(title = "保存退回原因", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/saveThyy", method = RequestMethod.POST)
    public AjaxResult saveThyy(@RequestBody Map<String, Object> parms) {
        try {
            Integer rest = wpzfNdhcSjshServiceImpl.saveThyy(parms);
            return AjaxResult.success("保存退回原因 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("保存退回原因 失败", ex.toString());
        }
    }


    //流程表

    //查询是否有地块提交到省级
    @RequestMapping(value = "/queryRelatedk", method = RequestMethod.POST)
    public AjaxResult queryRelatedk(@RequestBody Map<String, Object> parm) {
        //所有相关地块
        List<Map<String, Object>> rest = wpzfNdhcXjtbTbBaseService.queryRelatedk(parm);
        //未提交的地块
        List<String> tbbhs = new ArrayList<String>();
        //已经提交的地块
        List<String> tjtbbhs1 = new ArrayList<String>();
        //图斑已经被拆分  地块没有被提交到市级
        String str = "";
        if (rest != null) {
            if (rest.size() > 0) {
                for (int i = 0; i < rest.size(); i++) {
                    String tbbh = rest.get(i).get("tbbh").toString();
                    String dkzt = rest.get(i).get("dkzt").toString();
                    if (!dkzt.equals("8")) {
                        tbbhs.add(tbbh);
                        str += "(" + rest.get(i).get("tbbh") + ")";
                    } else {
                        tjtbbhs1.add(tbbh);
                        str += "(" + rest.get(i).get("tbbh") + ")";
                    }
                }
            }
            if (rest.size() == tbbhs.size() && tjtbbhs1.size() == 0) {
                return AjaxResult.success("获取关联图斑 成功", str);
            } else {
                return AjaxResult.error("获取关联图斑 成功", str);
            }
        }
        return AjaxResult.error("获取关联图斑 失败", -1);
    }

    @Log(title = "卫片核查反馈提交接口", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/tj", method = RequestMethod.POST)
    public AjaxResult tj(@RequestBody Map<String, Object> parms) {
        try {
            parms.put("type", "tj");
            String rest = wpzfNdhcSjshServiceImpl.getGtyData(parms);
            return AjaxResult.success("", rest);
        } catch (Exception ex) {
            return AjaxResult.error("提交失败", ex.toString());
        }
    }

    //暂存
    @RequestMapping(value = "/saveLz", method = RequestMethod.POST)
    public AjaxResult saveLz(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("czr", loginUser.getUsername());
            parm.put("realname", loginUser.getSysUser().getNickName());
            Integer rest = wpzfNdhcSjshServiceImpl.saveLz(parm);
            return AjaxResult.success("保存 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("保存 失败", ex.toString());
        }
    }


    //todo 年度省级调整

    @RequestMapping(value = "/getPch", method = RequestMethod.POST)
    public AjaxResult getPch(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("user_xzqdm", loginUser.getSysUser().getXzqdm());
        List<Map<String, Object>> rest = wpzfNdhcSjshServiceImpl.getPch(param);
        return AjaxResult.success("查询批次号", rest);
    }

    //查询市
    @RequestMapping(value = "/getShi", method = RequestMethod.POST)
    public AjaxResult getShi(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("user_xzqdm", loginUser.getSysUser().getXzqdm());
        List<Map<String, Object>> rest = wpzfNdhcSjshServiceImpl.getShi(param);
        return AjaxResult.success("查询市", rest);
    }

    //查询县
    @RequestMapping(value = "/getXian", method = RequestMethod.POST)
    public AjaxResult getXian(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("user_xzqdm", loginUser.getSysUser().getXzqdm());
        List<Map<String, Object>> rest = wpzfNdhcSjshServiceImpl.getXian(param);
        return AjaxResult.success("查询县", rest);
    }

    //根据用户市权限查询地块列表
    @RequestMapping(value = "/queryDkList", method = RequestMethod.POST)
    public AjaxResult queryDkList(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("user_xzqdm", loginUser.getSysUser().getXzqdm());
        List<Map<String, Object>> rest = wpzfNdhcSjshServiceImpl.queryDkList(param);
        Integer cnt = wpzfNdhcSjshServiceImpl.queryDkListCount(param);
        return AjaxResult.success("查询地块列表", rest, cnt);
    }

    //根据用户省市权限查询图斑信息列表  根据index查询
    @RequestMapping(value = "/queryDkByIndex", method = RequestMethod.POST)
    public AjaxResult queryDkByIndex(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("user_xzqdm", loginUser.getSysUser().getXzqdm());
        Map<String, Object> rest = wpzfNdhcSjshServiceImpl.queryDkByIndex(param);
        return AjaxResult.success("查询图斑", rest);
    }

    //年度地块审核详情
    @RequestMapping(value = "/queryDkDetails", method = RequestMethod.POST)
    public AjaxResult queryDkDetails(@RequestBody Map<String, Object> param) {
        Map<String, Object> rest = new HashMap<>();
        try {
//            String dkbh = param.get("dkbh") + "";
//            String xzqdm = param.get("xzqdm") + "";
//            String dkbsm = param.get("dkbsm") + "";
//            String tbbsm = param.get("tbbsm") + "";
//            String pch = param.get("pch") + "";

            //地块信息
            Map<String, Object> dkInfo = wpzfNdhcSjshServiceImpl.queryDkInfoByDkbh(param);

            //批文
            StringBuilder tdgypzwh = new StringBuilder(); //土地供应批准文号
            StringBuilder tdgypwly = new StringBuilder(); //土地供应批准来源
            StringBuilder tdgypzmj = new StringBuilder(); //土地供应批准面积
            StringBuilder tdgypzjg = new StringBuilder(); //土地供应批准机关
            StringBuilder tdgypzrq = new StringBuilder(); //土地供应批准日期
            StringBuilder tdgytdgypwlxejl = new StringBuilder(); //土地供应批准面积
            StringBuilder tdgypwlb = new StringBuilder(); //土地供应批文类别
            StringBuilder tdgypznydmj = new StringBuilder(); //土地供应批准农用地面积
            StringBuilder tdgypzgdmj = new StringBuilder(); //土地供应批准耕地面积
            StringBuilder tdgypzyjjbntmj = new StringBuilder(); //土地供应准基本农田面积
//
            StringBuilder zjggpzwh = new StringBuilder(); //增减挂钩批准文号
            StringBuilder zjggpwly = new StringBuilder(); //增减挂钩批文来源
            StringBuilder zjggpzmj = new StringBuilder(); //增减挂钩批准面积
            StringBuilder zjggpzjg = new StringBuilder(); //增减挂钩批准机关
            StringBuilder zjggpzrq = new StringBuilder(); //增减挂钩批准日期
            StringBuilder zjggtdgypwlxejl = new StringBuilder(); //增减挂批准面积
            StringBuilder zjggpwlb = new StringBuilder(); //增减挂批文类别
            StringBuilder zjggpznydmj = new StringBuilder(); //增减挂批准农用地面积
            StringBuilder zjggpzgdmj = new StringBuilder(); //增减挂批准耕地面积
            StringBuilder zjggpzyjjbntmj = new StringBuilder(); //增减挂批准基本农田面积
//
            StringBuilder gkfqdpzwh = new StringBuilder(); //工矿废弃地批准文号
            StringBuilder gkfqdpwly = new StringBuilder(); //工矿废弃地批文来源
            StringBuilder gkfqdpzmj = new StringBuilder(); //工矿废弃地批准面积
            StringBuilder gkfqdpzjg = new StringBuilder(); //工矿废弃地批准机关
            StringBuilder gkfqdpzrq = new StringBuilder(); //工矿废弃地批准日期
            StringBuilder gkfqdtdgypwlxejl = new StringBuilder(); //工矿废弃地批准面积
            StringBuilder gkfqdpwlb = new StringBuilder(); //工矿废弃地批文类别
            StringBuilder gkfqdpznydmj = new StringBuilder(); //工矿废弃地批准农用地面积
            StringBuilder gkfqdpzgdmj = new StringBuilder(); //工矿废弃地批准耕地面积
            StringBuilder gkfqdpzyjjbntmj = new StringBuilder();//工矿废弃地批准基本农田面积
//
            StringBuilder xxydpzwh = new StringBuilder(); //先行用地批准文号
            StringBuilder xxydpwly = new StringBuilder(); //先行用地批准来源
            StringBuilder xxydpzmj = new StringBuilder(); //先行用地批准面积
            StringBuilder xxydpzjg = new StringBuilder(); //先行用地批准机关
            StringBuilder xxydpzrq = new StringBuilder(); //先行用地批准日期
            StringBuilder xxydtdgypwlxejl = new StringBuilder(); //先行批准面积
            StringBuilder xxydpwlb = new StringBuilder(); //先行批文类别
            StringBuilder xxydpznydmj = new StringBuilder(); //先行批准农用地面积
            StringBuilder xxydpzgdmj = new StringBuilder(); //先行批准耕地面积
            StringBuilder xxydpzyjjbntmj = new StringBuilder(); //
//
            StringBuilder ssnydpzwh = new StringBuilder(); //设施农用地批准文号
            StringBuilder ssnydpwly = new StringBuilder(); //设施农用地批准来源
            StringBuilder ssnydpzmj = new StringBuilder(); //设施农用地批准面积
            StringBuilder ssnydpzjg = new StringBuilder(); //设施农用地批准机关
            StringBuilder ssnydpzrq = new StringBuilder(); //设施农用地批准日期
            StringBuilder ssnydtdgypwlxejl = new StringBuilder(); //设施农用地批准面积
            StringBuilder ssnydpwlb = new StringBuilder(); //设施农用地批文类别
            StringBuilder ssnydpznydmj = new StringBuilder(); //设施农用地批准农用地面积
            StringBuilder ssnydpzgdmj = new StringBuilder(); //设施农用地批准耕地面积
            StringBuilder ssnydpzyjjbntmj = new StringBuilder(); //设施农用地批准基本农田面积
//
            StringBuilder lsydpzwh = new StringBuilder(); //临时用地批准文号
            StringBuilder lsydpwly = new StringBuilder(); //临时用地批准来源
            StringBuilder lsydpzmj = new StringBuilder(); //临时用地批准面积
            StringBuilder lsydpzjg = new StringBuilder(); //临时用地批准机关
            StringBuilder lsydpzrq = new StringBuilder(); //临时用地批准日期
            StringBuilder lsydtdgypwlxejl = new StringBuilder(); //临时用地批准面积
            StringBuilder lsydpwlb = new StringBuilder(); //临时用地批文类别
            StringBuilder lsydpznydmj = new StringBuilder(); //临时用地批准农用地面积
            StringBuilder lsydpzgdmj = new StringBuilder(); //临时用地批准耕地面积
            StringBuilder lsydpzyjjbntmj = new StringBuilder(); //临时用地批准基本农田面积
//
            StringBuilder bdcqzspzwh = new StringBuilder(); //不动产权证书批准文号
            StringBuilder bdcqzspwly = new StringBuilder(); //不动产权证书批准来源
            StringBuilder bdcqzspzmj = new StringBuilder(); //不动产权证书批准面积
            StringBuilder bdcqzspzjg = new StringBuilder(); //不动产权证书批准机关
            StringBuilder bdcqzspzrq = new StringBuilder(); //不动产权证书批准日期
            StringBuilder bdcqzstdgypwlxejl = new StringBuilder(); //不动产权证批准面积
            StringBuilder bdcqzspwlb = new StringBuilder(); //不动产权证批文类别
            StringBuilder bdcqzspznydmj = new StringBuilder(); //不动产权证批准农用地面积
            StringBuilder bdcqzspzgdmj = new StringBuilder(); //不动产权证批准耕地面积
            StringBuilder bdcqzspzyjjbntmj = new StringBuilder(); //不动产权证批准基本农田面积
//
            StringBuilder nydzypzwh = new StringBuilder(); //农用地转用批准文号
            StringBuilder nydzypwly = new StringBuilder(); //农用地转用批文来源
            StringBuilder nydzypzmj = new StringBuilder(); //农用地转用批准面积
            StringBuilder nydzypzjg = new StringBuilder(); //农用地转用批准机关
            StringBuilder nydzypzrq = new StringBuilder(); //农用地转用批准日期
            StringBuilder nydzytdgypwlxejl = new StringBuilder(); //农用地批准面积
            StringBuilder nydzypwlb = new StringBuilder(); //农用地批文类别
            StringBuilder nydzypznydmj = new StringBuilder(); //农用地批准农用地面积
            StringBuilder nydzypzgdmj = new StringBuilder(); //农用地批准耕地面积
            StringBuilder nydzypzyjjbntmj = new StringBuilder(); //农用地批准基本农田面积
//
            StringBuilder qtpzwh = new StringBuilder(); //
            StringBuilder qtpwly = new StringBuilder(); //
            StringBuilder qtpzmj = new StringBuilder(); //
            StringBuilder qtpzjg = new StringBuilder(); //
            StringBuilder qtpzrq = new StringBuilder(); //
            StringBuilder qttdgypwlxejl = new StringBuilder(); //
            StringBuilder qtpwlb = new StringBuilder(); //
            StringBuilder qtpznydmj = new StringBuilder(); //
            StringBuilder qtpzgdmj = new StringBuilder(); //
            StringBuilder qtpzyjjbntmj = new StringBuilder(); //

            List<WpSjsbDkpwjbbxxNdDTO> dkpwList = wpzfNdhcSjshServiceImpl.queryDkpwjbxxByDkbsm(param);
            for (WpSjsbDkpwjbbxxNdDTO wpSjsbDkpwjbbxxNdDTO : dkpwList) {
                List<WpSjsbDkfjjbxxNdDTO> fjInfo = wpzfNdhcShijshServiceImpl.queryDkfjjbxxByPwtbbsm(wpSjsbDkpwjbbxxNdDTO);
                wpSjsbDkpwjbbxxNdDTO.setFjInfo(fjInfo);
            }

            rest.put("dkpwInfo", dkpwList);
            if (dkpwList != null && dkpwList.size() > 0) {
                for (WpSjsbDkpwjbbxxNdDTO wpSjsbDkpwjbbxxNdDTO : dkpwList) {
                    String pzwhlx = wpSjsbDkpwjbbxxNdDTO.getPzwhlx();

                    if ("NYDZY".equals(pzwhlx)) {
                        //农转用专用
                        if (nydzypzwh.length() > 0) {
                            nydzypzwh.append(",");
                        }
                        nydzypzwh.append(wpSjsbDkpwjbbxxNdDTO.getPzwh());
                        if (nydzypwly.length() > 0) {
                            nydzypwly.append(",");
                        }
                        nydzypwly.append(wpSjsbDkpwjbbxxNdDTO.getPwlymc());
                        if (nydzypzmj.length() > 0) {
                            nydzypzmj.append(",");
                        }
                        nydzypzmj.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (nydzypzjg.length() > 0) {
                            nydzypzjg.append(",");
                        }
                        nydzypzjg.append(wpSjsbDkpwjbbxxNdDTO.getPzjg());
                        if (nydzypzrq.length() > 0) {
                            nydzypzrq.append(",");
                        }
                        nydzypzrq.append(wpSjsbDkpwjbbxxNdDTO.getPzsj());
                        if (nydzytdgypwlxejl.length() > 0) {
                            nydzytdgypwlxejl.append(",");
                        }
                        nydzytdgypwlxejl.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (nydzypwlb.length() > 0) {
                            nydzypwlb.append(",");
                        }
                        nydzypwlb.append(wpSjsbDkpwjbbxxNdDTO.getPwlbmc());
                        if (nydzypznydmj.length() > 0) {
                            nydzypznydmj.append(",");
                        }
                        nydzypznydmj.append(wpSjsbDkpwjbbxxNdDTO.getPznydmj());
                        if (nydzypzgdmj.length() > 0) {
                            nydzypzgdmj.append(",");
                        }
                        nydzypzgdmj.append(wpSjsbDkpwjbbxxNdDTO.getPzgdmj());
                        if (nydzypzyjjbntmj.length() > 0) {
                            nydzypzyjjbntmj.append(",");
                        }
                        nydzypzyjjbntmj.append(wpSjsbDkpwjbbxxNdDTO.getPzyjjbntmj());
                    } else if ("ZJJG".equals(pzwhlx)) {
                        //增减挂钩
                        if (zjggpzwh.length() > 0) {
                            zjggpzwh.append(",");
                        }
                        zjggpzwh.append(wpSjsbDkpwjbbxxNdDTO.getPzwh());
                        if (zjggpwly.length() > 0) {
                            zjggpwly.append(",");
                        }
                        zjggpwly.append(wpSjsbDkpwjbbxxNdDTO.getPwlymc());
                        if (zjggpzmj.length() > 0) {
                            zjggpzmj.append(",");
                        }
                        zjggpzmj.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (zjggpzjg.length() > 0) {
                            zjggpzjg.append(",");
                        }
                        zjggpzjg.append(wpSjsbDkpwjbbxxNdDTO.getPzjg());
                        if (zjggpzrq.length() > 0) {
                            zjggpzrq.append(",");
                        }
                        zjggpzrq.append(wpSjsbDkpwjbbxxNdDTO.getPzsj());
                        if (zjggtdgypwlxejl.length() > 0) {
                            zjggtdgypwlxejl.append(",");
                        }
                        zjggtdgypwlxejl.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (zjggpwlb.length() > 0) {
                            zjggpwlb.append(",");
                        }
                        zjggpwlb.append(wpSjsbDkpwjbbxxNdDTO.getPwlbmc());
                        if (zjggpznydmj.length() > 0) {
                            zjggpznydmj.append(",");
                        }
                        zjggpznydmj.append(wpSjsbDkpwjbbxxNdDTO.getPznydmj());
                        if (zjggpzgdmj.length() > 0) {
                            zjggpzgdmj.append(",");
                        }
                        zjggpzgdmj.append(wpSjsbDkpwjbbxxNdDTO.getPzgdmj());
                        if (zjggpzyjjbntmj.length() > 0) {
                            zjggpzyjjbntmj.append(",");
                        }
                        zjggpzyjjbntmj.append(wpSjsbDkpwjbbxxNdDTO.getPzyjjbntmj());
                    } else if ("GKFQD".equals(pzwhlx)) {
                        //工矿废弃地复垦建新
                        if (gkfqdpzwh.length() > 0) {
                            gkfqdpzwh.append(",");
                        }
                        gkfqdpzwh.append(wpSjsbDkpwjbbxxNdDTO.getPzwh());
                        if (gkfqdpwly.length() > 0) {
                            gkfqdpwly.append(",");
                        }
                        gkfqdpwly.append(wpSjsbDkpwjbbxxNdDTO.getPwlymc());
                        if (gkfqdpzmj.length() > 0) {
                            gkfqdpzmj.append(",");
                        }
                        gkfqdpzmj.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (gkfqdpzjg.length() > 0) {
                            gkfqdpzjg.append(",");
                        }
                        gkfqdpzjg.append(wpSjsbDkpwjbbxxNdDTO.getPzjg());
                        if (gkfqdpzrq.length() > 0) {
                            gkfqdpzrq.append(",");
                        }
                        gkfqdpzrq.append(wpSjsbDkpwjbbxxNdDTO.getPzsj());
                        if (gkfqdtdgypwlxejl.length() > 0) {
                            gkfqdtdgypwlxejl.append(",");
                        }
                        gkfqdtdgypwlxejl.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (gkfqdpwlb.length() > 0) {
                            gkfqdpwlb.append(",");
                        }
                        gkfqdpwlb.append(wpSjsbDkpwjbbxxNdDTO.getPwlbmc());
                        if (gkfqdpznydmj.length() > 0) {
                            gkfqdpznydmj.append(",");
                        }
                        gkfqdpznydmj.append(wpSjsbDkpwjbbxxNdDTO.getPznydmj());
                        if (gkfqdpzgdmj.length() > 0) {
                            gkfqdpzgdmj.append(",");
                        }
                        gkfqdpzgdmj.append(wpSjsbDkpwjbbxxNdDTO.getPzgdmj());
                        if (gkfqdpzyjjbntmj.length() > 0) {
                            gkfqdpzyjjbntmj.append(",");
                        }
                        gkfqdpzyjjbntmj.append(wpSjsbDkpwjbbxxNdDTO.getPzyjjbntmj());
                    } else if ("TDGY".equals(pzwhlx)) {
                        //土地供应
                        if (tdgypzwh.length() > 0) {
                            tdgypzwh.append(",");
                        }
                        tdgypzwh.append(wpSjsbDkpwjbbxxNdDTO.getPzwh());
                        if (tdgypwly.length() > 0) {
                            tdgypwly.append(",");
                        }
                        tdgypwly.append(wpSjsbDkpwjbbxxNdDTO.getPwlymc());
                        if (tdgypzmj.length() > 0) {
                            tdgypzmj.append(",");
                        }
                        tdgypzmj.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (tdgypzjg.length() > 0) {
                            tdgypzjg.append(",");
                        }
                        tdgypzjg.append(wpSjsbDkpwjbbxxNdDTO.getPzjg());
                        if (tdgypzrq.length() > 0) {
                            tdgypzrq.append(",");
                        }
                        tdgypzrq.append(wpSjsbDkpwjbbxxNdDTO.getPzsj());
                        if (tdgytdgypwlxejl.length() > 0) {
                            tdgytdgypwlxejl.append(",");
                        }
                        tdgytdgypwlxejl.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (tdgypwlb.length() > 0) {
                            tdgypwlb.append(",");
                        }
                        tdgypwlb.append(wpSjsbDkpwjbbxxNdDTO.getPwlbmc());
                        if (tdgypznydmj.length() > 0) {
                            tdgypznydmj.append(",");
                        }
                        tdgypznydmj.append(wpSjsbDkpwjbbxxNdDTO.getPznydmj());
                        if (tdgypzgdmj.length() > 0) {
                            tdgypzgdmj.append(",");
                        }
                        tdgypzgdmj.append(wpSjsbDkpwjbbxxNdDTO.getPzgdmj());
                        if (tdgypzyjjbntmj.length() > 0) {
                            tdgypzyjjbntmj.append(",");
                        }
                        tdgypzyjjbntmj.append(wpSjsbDkpwjbbxxNdDTO.getPzyjjbntmj());
                    } else if ("XXYD".equals(pzwhlx)) {
                        //先行用地
                        if (xxydpzwh.length() > 0) {
                            xxydpzwh.append(",");
                        }
                        xxydpzwh.append(wpSjsbDkpwjbbxxNdDTO.getPzwh());
                        if (xxydpwly.length() > 0) {
                            xxydpwly.append(",");
                        }
                        xxydpwly.append(wpSjsbDkpwjbbxxNdDTO.getPwlymc());
                        if (xxydpzmj.length() > 0) {
                            xxydpzmj.append(",");
                        }
                        xxydpzmj.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (xxydpzjg.length() > 0) {
                            xxydpzjg.append(",");
                        }
                        xxydpzjg.append(wpSjsbDkpwjbbxxNdDTO.getPzjg());
                        if (xxydpzrq.length() > 0) {
                            xxydpzrq.append(",");
                        }
                        xxydpzrq.append(wpSjsbDkpwjbbxxNdDTO.getPzsj());
                        if (xxydtdgypwlxejl.length() > 0) {
                            xxydtdgypwlxejl.append(",");
                        }
                        xxydtdgypwlxejl.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (xxydpwlb.length() > 0) {
                            xxydpwlb.append(",");
                        }
                        xxydpwlb.append(wpSjsbDkpwjbbxxNdDTO.getPwlbmc());
                        if (xxydpznydmj.length() > 0) {
                            xxydpznydmj.append(",");
                        }
                        xxydpznydmj.append(wpSjsbDkpwjbbxxNdDTO.getPznydmj());
                        if (xxydpzgdmj.length() > 0) {
                            xxydpzgdmj.append(",");
                        }
                        xxydpzgdmj.append(wpSjsbDkpwjbbxxNdDTO.getPzgdmj());
                        if (xxydpzyjjbntmj.length() > 0) {
                            xxydpzyjjbntmj.append(",");
                        }
                        xxydpzyjjbntmj.append(wpSjsbDkpwjbbxxNdDTO.getPzyjjbntmj());
                    } else if ("SSNYD".equals(pzwhlx)) {
                        //设施农用地
                        if (ssnydpzwh.length() > 0) {
                            ssnydpzwh.append(",");
                        }
                        ssnydpzwh.append(wpSjsbDkpwjbbxxNdDTO.getPzwh());
                        if (ssnydpwly.length() > 0) {
                            ssnydpwly.append(",");
                        }
                        ssnydpwly.append(wpSjsbDkpwjbbxxNdDTO.getPwlymc());
                        if (ssnydpzmj.length() > 0) {
                            ssnydpzmj.append(",");
                        }
                        ssnydpzmj.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (ssnydpzjg.length() > 0) {
                            ssnydpzjg.append(",");
                        }
                        ssnydpzjg.append(wpSjsbDkpwjbbxxNdDTO.getPzjg());
                        if (ssnydpzrq.length() > 0) {
                            ssnydpzrq.append(",");
                        }
                        ssnydpzrq.append(wpSjsbDkpwjbbxxNdDTO.getPzsj());
                        if (ssnydtdgypwlxejl.length() > 0) {
                            ssnydtdgypwlxejl.append(",");
                        }
                        ssnydtdgypwlxejl.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (ssnydpwlb.length() > 0) {
                            ssnydpwlb.append(",");
                        }
                        ssnydpwlb.append(wpSjsbDkpwjbbxxNdDTO.getPwlbmc());
                        if (ssnydpznydmj.length() > 0) {
                            ssnydpznydmj.append(",");
                        }
                        ssnydpznydmj.append(wpSjsbDkpwjbbxxNdDTO.getPznydmj());
                        if (ssnydpzgdmj.length() > 0) {
                            ssnydpzgdmj.append(",");
                        }
                        ssnydpzgdmj.append(wpSjsbDkpwjbbxxNdDTO.getPzgdmj());
                        if (ssnydpzyjjbntmj.length() > 0) {
                            ssnydpzyjjbntmj.append(",");
                        }
                        ssnydpzyjjbntmj.append(wpSjsbDkpwjbbxxNdDTO.getPzyjjbntmj());
                    } else if ("LSYD".equals(pzwhlx)) {
                        //临时用地
                        if (lsydpzwh.length() > 0) {
                            lsydpzwh.append(",");
                        }
                        lsydpzwh.append(wpSjsbDkpwjbbxxNdDTO.getPzwh());
                        if (lsydpwly.length() > 0) {
                            lsydpwly.append(",");
                        }
                        lsydpwly.append(wpSjsbDkpwjbbxxNdDTO.getPwlymc());
                        if (lsydpzmj.length() > 0) {
                            lsydpzmj.append(",");
                        }
                        lsydpzmj.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (lsydpzjg.length() > 0) {
                            lsydpzjg.append(",");
                        }
                        lsydpzjg.append(wpSjsbDkpwjbbxxNdDTO.getPzjg());
                        if (lsydpzrq.length() > 0) {
                            lsydpzrq.append(",");
                        }
                        lsydpzrq.append(wpSjsbDkpwjbbxxNdDTO.getPzsj());
                        if (lsydtdgypwlxejl.length() > 0) {
                            lsydtdgypwlxejl.append(",");
                        }
                        lsydtdgypwlxejl.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (lsydpwlb.length() > 0) {
                            lsydpwlb.append(",");
                        }
                        lsydpwlb.append(wpSjsbDkpwjbbxxNdDTO.getPwlbmc());
                        if (lsydpznydmj.length() > 0) {
                            lsydpznydmj.append(",");
                        }
                        lsydpznydmj.append(wpSjsbDkpwjbbxxNdDTO.getPznydmj());
                        if (lsydpzgdmj.length() > 0) {
                            lsydpzgdmj.append(",");
                        }
                        lsydpzgdmj.append(wpSjsbDkpwjbbxxNdDTO.getPzgdmj());
                        if (lsydpzyjjbntmj.length() > 0) {
                            lsydpzyjjbntmj.append(",");
                        }
                        lsydpzyjjbntmj.append(wpSjsbDkpwjbbxxNdDTO.getPzyjjbntmj());
                    } else if ("BDCQZS".equals(pzwhlx)) {
                        //不动产权证书(含土地使用权证等)
                        if (bdcqzspzwh.length() > 0) {
                            bdcqzspzwh.append(",");
                        }
                        bdcqzspzwh.append(wpSjsbDkpwjbbxxNdDTO.getPzwh());
                        if (bdcqzspwly.length() > 0) {
                            bdcqzspwly.append(",");
                        }
                        bdcqzspwly.append(wpSjsbDkpwjbbxxNdDTO.getPwlymc());
                        if (bdcqzspzmj.length() > 0) {
                            bdcqzspzmj.append(",");
                        }
                        bdcqzspzmj.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (bdcqzspzjg.length() > 0) {
                            bdcqzspzjg.append(",");
                        }
                        bdcqzspzjg.append(wpSjsbDkpwjbbxxNdDTO.getPzjg());
                        if (bdcqzspzrq.length() > 0) {
                            bdcqzspzrq.append(",");
                        }
                        bdcqzspzrq.append(wpSjsbDkpwjbbxxNdDTO.getPzsj());
                        if (bdcqzstdgypwlxejl.length() > 0) {
                            bdcqzstdgypwlxejl.append(",");
                        }
                        bdcqzstdgypwlxejl.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (bdcqzspwlb.length() > 0) {
                            bdcqzspwlb.append(",");
                        }
                        bdcqzspwlb.append(wpSjsbDkpwjbbxxNdDTO.getPwlbmc());
                        if (bdcqzspznydmj.length() > 0) {
                            bdcqzspznydmj.append(",");
                        }
                        bdcqzspznydmj.append(wpSjsbDkpwjbbxxNdDTO.getPznydmj());
                        if (bdcqzspzgdmj.length() > 0) {
                            bdcqzspzgdmj.append(",");
                        }
                        bdcqzspzgdmj.append(wpSjsbDkpwjbbxxNdDTO.getPzgdmj());
                        if (bdcqzspzyjjbntmj.length() > 0) {
                            bdcqzspzyjjbntmj.append(",");
                        }
                        bdcqzspzyjjbntmj.append(wpSjsbDkpwjbbxxNdDTO.getPzyjjbntmj());
                    } else if ("QT".equals(pzwhlx)) {
                        //其他
                        if (qtpzwh.length() > 0) {
                            qtpzwh.append(",");
                        }
                        qtpzwh.append(wpSjsbDkpwjbbxxNdDTO.getPzwh());
                        if (qtpwly.length() > 0) {
                            qtpwly.append(",");
                        }
                        qtpwly.append(wpSjsbDkpwjbbxxNdDTO.getPwlymc());
                        if (qtpzmj.length() > 0) {
                            qtpzmj.append(",");
                        }
                        qtpzmj.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (qtpzjg.length() > 0) {
                            qtpzjg.append(",");
                        }
                        qtpzjg.append(wpSjsbDkpwjbbxxNdDTO.getPzjg());
                        if (qtpzrq.length() > 0) {
                            qtpzrq.append(",");
                        }
                        qtpzrq.append(wpSjsbDkpwjbbxxNdDTO.getPzsj());
                        if (qttdgypwlxejl.length() > 0) {
                            qttdgypwlxejl.append(",");
                        }
                        qttdgypwlxejl.append(wpSjsbDkpwjbbxxNdDTO.getPzmj());
                        if (qtpwlb.length() > 0) {
                            qtpwlb.append(",");
                        }
                        qtpwlb.append(wpSjsbDkpwjbbxxNdDTO.getPwlbmc());
                        if (qtpznydmj.length() > 0) {
                            qtpznydmj.append(",");
                        }
                        qtpznydmj.append(wpSjsbDkpwjbbxxNdDTO.getPznydmj());
                        if (qtpzgdmj.length() > 0) {
                            qtpzgdmj.append(",");
                        }
                        qtpzgdmj.append(wpSjsbDkpwjbbxxNdDTO.getPzgdmj());
                        if (qtpzyjjbntmj.length() > 0) {
                            qtpzyjjbntmj.append(",");
                        }
                        qtpzyjjbntmj.append(wpSjsbDkpwjbbxxNdDTO.getPzyjjbntmj());
                    }
                }
            }

            dkInfo.put("pwCount", dkpwList != null && dkpwList.size() > 0 ? dkpwList.size() : 0);
            dkInfo.put("tdgypzwh", tdgypzwh.toString());
            dkInfo.put("tdgypwly", tdgypwly.toString());
            dkInfo.put("tdgypzmj", tdgypzmj.toString());
            dkInfo.put("tdgypzjg", tdgypzjg.toString());
            dkInfo.put("tdgypzrq", tdgypzrq.toString());
            dkInfo.put("tdgytdgypwlxejl", tdgytdgypwlxejl.toString());
            dkInfo.put("tdgypznydmj", tdgypznydmj.toString());
            dkInfo.put("tdgypzgdmj", tdgypzgdmj.toString());
            dkInfo.put("tdgypzyjjbntmj", tdgypzyjjbntmj.toString());
            dkInfo.put("zjggpzwh", zjggpzwh.toString());
            dkInfo.put("zjggpwly", zjggpwly.toString());
            dkInfo.put("zjggpzmj", zjggpzmj.toString());
            dkInfo.put("zjggpzjg", zjggpzjg.toString());
            dkInfo.put("zjggpzrq", zjggpzrq.toString());
            dkInfo.put("zjggtdgypwlxejl", zjggtdgypwlxejl.toString());
            dkInfo.put("zjggpwlb", zjggpwlb.toString());
            dkInfo.put("zjggpznydmj", zjggpznydmj.toString());
            dkInfo.put("zjggpzgdmj", zjggpzgdmj.toString());
            dkInfo.put("zjggpzyjjbntmj", zjggpzyjjbntmj.toString());
            dkInfo.put("gkfqdpzwh", gkfqdpzwh.toString());
            dkInfo.put("gkfqdpwly", gkfqdpwly.toString());
            dkInfo.put("gkfqdpzmj", gkfqdpzmj.toString());
            dkInfo.put("gkfqdpzjg", gkfqdpzjg.toString());
            dkInfo.put("gkfqdpzrq", gkfqdpzrq.toString());
            dkInfo.put("gkfqdtdgypwlxejl", gkfqdtdgypwlxejl.toString());
            dkInfo.put("gkfqdpwlb", gkfqdpwlb.toString());
            dkInfo.put("gkfqdpznydmj", gkfqdpznydmj.toString());
            dkInfo.put("gkfqdpzgdmj", gkfqdpzgdmj.toString());
            dkInfo.put("gkfqdpzyjjbntmj", gkfqdpzyjjbntmj.toString());
            dkInfo.put("xxydpzwh", xxydpzwh.toString());
            dkInfo.put("xxydpwly", xxydpwly.toString());
            dkInfo.put("xxydpzmj", xxydpzmj.toString());
            dkInfo.put("xxydpzjg", xxydpzjg.toString());
            dkInfo.put("xxydpzrq", xxydpzrq.toString());
            dkInfo.put("xxydtdgypwlxejl", xxydtdgypwlxejl.toString());
            dkInfo.put("xxydpwlb", xxydpwlb.toString());
            dkInfo.put("xxydpznydmj", xxydpznydmj.toString());
            dkInfo.put("xxydpzgdmj", xxydpzgdmj.toString());
            dkInfo.put("xxydpzyjjbntmj", xxydpzyjjbntmj.toString());
            dkInfo.put("ssnydpzwh", ssnydpzwh.toString());
            dkInfo.put("ssnydpwly", ssnydpwly.toString());
            dkInfo.put("ssnydpzmj", ssnydpzmj.toString());
            dkInfo.put("ssnydpzjg", ssnydpzjg.toString());
            dkInfo.put("ssnydpzrq", ssnydpzrq.toString());
            dkInfo.put("ssnydtdgypwlxejl", ssnydtdgypwlxejl.toString());
            dkInfo.put("ssnydpwlb", ssnydpwlb.toString());
            dkInfo.put("ssnydpznydmj", ssnydpznydmj.toString());
            dkInfo.put("ssnydpzgdmj", ssnydpzgdmj.toString());
            dkInfo.put("ssnydpzyjjbntmj", ssnydpzyjjbntmj.toString());
            dkInfo.put("lsydpzwh", lsydpzwh.toString());
            dkInfo.put("lsydpwly", lsydpwly.toString());
            dkInfo.put("lsydpzmj", lsydpzmj.toString());
            dkInfo.put("lsydpzjg", lsydpzjg.toString());
            dkInfo.put("lsydpzrq", lsydpzrq.toString());
            dkInfo.put("lsydtdgypwlxejl", lsydtdgypwlxejl.toString());
            dkInfo.put("lsydpwlb", lsydpwlb.toString());
            dkInfo.put("lsydpznydmj", lsydpznydmj.toString());
            dkInfo.put("lsydpzgdmj", lsydpzgdmj.toString());
            dkInfo.put("lsydpzyjjbntmj", lsydpzyjjbntmj.toString());
            dkInfo.put("bdcqzspzwh", bdcqzspzwh.toString());
            dkInfo.put("bdcqzspwly", bdcqzspwly.toString());
            dkInfo.put("bdcqzspzmj", bdcqzspzmj.toString());
            dkInfo.put("bdcqzspzjg", bdcqzspzjg.toString());
            dkInfo.put("bdcqzspzrq", bdcqzspzrq.toString());
            dkInfo.put("bdcqzstdgypwlxejl", bdcqzstdgypwlxejl.toString());
            dkInfo.put("bdcqzspwlb", bdcqzspwlb.toString());
            dkInfo.put("bdcqzspznydmj", bdcqzspznydmj.toString());
            dkInfo.put("bdcqzspzgdmj", bdcqzspzgdmj.toString());
            dkInfo.put("bdcqzspzyjjbntmj", bdcqzspzyjjbntmj.toString());
            dkInfo.put("nydzypzwh", nydzypzwh.toString());
            dkInfo.put("nydzypwly", nydzypwly.toString());
            dkInfo.put("nydzypzmj", nydzypzmj.toString());
            dkInfo.put("nydzypzjg", nydzypzjg.toString());
            dkInfo.put("nydzypzrq", nydzypzrq.toString());
            dkInfo.put("nydzytdgypwlxejl", nydzytdgypwlxejl.toString());
            dkInfo.put("nydzypwlb", nydzypwlb.toString());
            dkInfo.put("nydzypznydmj", nydzypznydmj.toString());
            dkInfo.put("nydzypzgdmj", nydzypzgdmj.toString());
            dkInfo.put("nydzypzyjjbntmj", nydzypzyjjbntmj.toString());
            dkInfo.put("qtpzwh", qtpzwh.toString());
            dkInfo.put("qtpwly", qtpwly.toString());
            dkInfo.put("qtpzmj", qtpzmj.toString());
            dkInfo.put("qtpzjg", qtpzjg.toString());
            dkInfo.put("qtpzrq", qtpzrq.toString());
            dkInfo.put("qttdgypwlxejl", qttdgypwlxejl.toString());
            dkInfo.put("qtpwlb", qtpwlb.toString());
            dkInfo.put("qtpznydmj", qtpznydmj.toString());
            dkInfo.put("qtpzgdmj", qtpzgdmj.toString());
            dkInfo.put("qtpzyjjbntmj", qtpzyjjbntmj.toString());

            rest.put("dkInfo", dkInfo);

            //核查附件
            List<WpSjHcfjNdDTO> wpSjHcfjNdDTOList = wpzfNdhcShijshServiceImpl.querySjHcfjByDkbsm(param);
            rest.put("hcfj", wpSjHcfjNdDTOList);

            //结果
            Map<String, Object> resultInfo = wpzfNdhcSjshServiceImpl.queryResult(param);
            rest.put("resultInfo", resultInfo);

            //市级结果
            Map<String, Object> shiResultInfo = wpzfNdhcShijshServiceImpl.queryDkshjgShijiByDkbh(param);
            rest.put("shiResultInfo", shiResultInfo);

            //流转
            List<Map<String, Object>> lzInfo = wpzfNdhcSjshServiceImpl.queryLzByDkbh(param);
            rest.put("lzInfo", lzInfo);

            //相关地块信息
            List<Map<String, Object>> relevantDk = wpzfNdhcSjshServiceImpl.queryRelevantDkByDkbh(param);
            rest.put("relevantDk", relevantDk);

            //图斑信息
            Map<String, Object> tbInfo = wpzfNdhcSjshServiceImpl.queryTbInfo(param);
            rest.put("tbInfo", tbInfo);

            //举证照片
//            ModelMap modelMap = WpzfNdhcTbBaseInfoController.getShowImgs(param);
//            rest.put("modelMap", modelMap);

            //附件
            List<WpSjsbDkfjjbxxNdDTO> dkfjjbxxInfo = wpzfNdhcSjshServiceImpl.queryDkfjjbxxByDkbsm(param);
            rest.put("dkfjjbxxInfo", dkfjjbxxInfo);

        } catch (Exception e) {
            System.err.println(e.getMessage());
            return AjaxResult.error("查询地块详情失败");
        }
        return AjaxResult.success("查询地块详情", rest);
    }


    //导出地块列表
    @RequestMapping(value = "/exportDkList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public AjaxResult exportDkList(@RequestBody Map<String, Object> param, HttpServletResponse response) {
        String rest = "";
        String msg = "";
        WpzfNdhcExcelUtils excel = new WpzfNdhcExcelUtils();
        List<String> Colomnlist = new ArrayList<>();
        Colomnlist.clear();
        Colomnlist.add("序号");
        Colomnlist.add("地块标识码");
        Colomnlist.add("图斑标识码");
        Colomnlist.add("市级行政区代码");
        Colomnlist.add("市级行政区名称");
        Colomnlist.add("县级行政区代码");
        Colomnlist.add("县级行政区名称");
        Colomnlist.add("地块编号");
        Colomnlist.add("地块名称");
        Colomnlist.add("地块面积");
        Colomnlist.add("地块中心点X坐标");
        Colomnlist.add("地块中心点Y坐标");
        Colomnlist.add("备注信息");
        Colomnlist.add("扩展信息");
        Colomnlist.add("判定类型");
        Colomnlist.add("在变更调查中是否按建设用地变更");
        Colomnlist.add("是否违法");
        Colomnlist.add("耕地面积");
        Colomnlist.add("其他农用地面积");
        Colomnlist.add("建设用地面积");
        Colomnlist.add("未利用地面积");

        Colomnlist.add("违法的判定依据说明");
        Colomnlist.add("项目名称");
        Colomnlist.add("项目主体");
        Colomnlist.add("项目类型");
        Colomnlist.add("立项批准机关");
        Colomnlist.add("立项批准文号");
        Colomnlist.add("是否立案");

        Colomnlist.add("审核结论");
        Colomnlist.add("审核说明");


        String operName = SecurityUtils.getUsername();
        param.put("username", operName);
        //获取地块列表
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("user_xzqdm", loginUser.getSysUser().getXzqdm());
        List<Map<String, Object>> list = wpzfNdhcSjshServiceImpl.queryDkList(param);
        rest = excel.exportDkList(response, "地块列表", list, Colomnlist, tempath);
        if (rest.contains("error")) {
            msg = "导出失败";
        } else {
            msg = "导出成功";
        }
        return AjaxResult.success(msg, rest);
    }

    MultipleFileUnZip multipleFileUnZip = new MultipleFileUnZip();

    //导出矢量数据
    @RequestMapping(value = "/exportDkShpList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public AjaxResult exportDkShpList(@RequestBody Map<String, Object> param, HttpServletResponse response) throws ZipException {
        String rest = "";
        String msg = "";
        WpzfNdhcGdalUtils gdalUtils = new WpzfNdhcGdalUtils();
        String operName = SecurityUtils.getUsername();
        param.put("username", operName);
        //获取图斑列表
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("user_xzqdm", loginUser.getSysUser().getXzqdm());
        List<Map<String, Object>> list = wpzfNdhcSjshServiceImpl.queryDkList(param);
        rest = gdalUtils.exportDkList(response, list, tempath);
        if (rest.contains("error")) {
            msg = "导出失败";
        } else {
            List<String> arr = new ArrayList<>();
            arr.add(tempath + "\\" + rest);  //shp
            String zippath = tempath + "\\" + rest.replace("shp", "zip");
            //生成了shp
            String str = tempath + "\\" + rest.replace("shp", "prj");
            File file = new File(str);
            if (file.exists()) {
                arr.add(str);  //prj
            }

            str = tempath + "\\" + rest.replace("shp", "dbf");
            file = new File(str);
            if (file.exists()) {
                arr.add(str);  //prj
            }
            str = tempath + "\\" + rest.replace("shp", "shx");
            file = new File(str);
            if (file.exists()) {
                arr.add(str);  //prj
            }
            rest = multipleFileUnZip.fileZip(zippath, arr);
            if (rest == "") {
                File file1 = new File(zippath);
                rest = file1.getName();
                msg = "导出成功";
            } else {
                msg = "导出失败";
            }
        }
        return AjaxResult.success(msg, rest);
    }

    //保存结果 有相同的更新，没有添加
    @RequestMapping(value = "/saveShengDkshjg", method = RequestMethod.POST)
    public AjaxResult saveShengDkshjg(@RequestBody Map<String, Object> param) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            param.put("shr", loginUser.getUsername());
            Integer rest = wpzfNdhcSjshServiceImpl.saveShengDkshjg(param);
            if (rest > 0) {
                wpzfNdhcSjshServiceImpl.updateHcjgsm(param);
                return AjaxResult.success("保存 成功", rest);
            } else {
                return AjaxResult.error("保存 失败");
            }
        } catch (Exception ex) {
            return AjaxResult.error("保存 失败", ex.toString());
        }
    }

    //保存并提交结果 有相同的更新，没有添加 提交后改为8（国家） 记录流转信息
    @RequestMapping(value = "/submitShengDkshjg", method = RequestMethod.POST)
    public AjaxResult submitShengDkshjg(@RequestBody Map<String, Object> param) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            param.put("shr", loginUser.getUsername());
            param.put("username", loginUser.getUsername());
            param.put("nickname", loginUser.getSysUser().getNickName());
            Integer rest = wpzfNdhcSjshServiceImpl.submitShengDkshjg(param);
            if (rest > 0) {
                wpzfNdhcSjshServiceImpl.updateHcjgsm(param);
                return AjaxResult.success("提交 成功", rest);
            } else {
                return AjaxResult.error("提交 失败");
            }
        } catch (Exception ex) {
            return AjaxResult.error("市级提交到省级 失败", ex.toString());
        }
    }

    //获取已做完未提交的地块列表
    @RequestMapping(value = "/queryUnsubmittedDkList", method = RequestMethod.POST)
    public AjaxResult queryUnsubmittedDkList(@RequestBody Map<String, Object> param) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        param.put("user_xzqdm", loginUser.getSysUser().getXzqdm());
        if (param.get("shjg") != null && param.get("shjg") != "") {
            if (("").equals(param.get("shjg").toString())) {
                return AjaxResult.error("高级筛选中只能选择通过或者不通过进行提交");
            }
            if (("全部").equals(param.get("shjg").toString())) {
                param.replace("shjg", "");
            }
        }
        List<Map<String, Object>> rest = wpzfNdhcSjshServiceImpl.queryUnsubmittedDkList(param);
        Integer cnt = wpzfNdhcSjshServiceImpl.queryUnsubmittedDkListCount(param);
        return AjaxResult.success("获取已做完未提交的地块列表", rest, cnt);
    }

    //接收未提交数据进行批量提交
    @RequestMapping(value = "/submitData", method = RequestMethod.POST)
    public AjaxResult submitData(@RequestBody Map<String, Object> params) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        params.put("user_xzqdm", loginUser.getSysUser().getXzqdm());
        List<Map<String, Object>> list = wpzfNdhcSjshServiceImpl.queryUnsubmittedDkList(params);
        String rest = wpzfNdhcSjshServiceImpl.submitData(list);
        if ("".equals(rest) || rest == null) {
            return AjaxResult.success("提交成功");
        } else {
            return AjaxResult.error("提交失败：" + rest + "无法提交到国土云");
        }

    }


}
